﻿using BusinessLogic.Connectivity.Entities;
using BusinessLogic.Mappers.DocumentEnvelopeStatus.Mapping;
using BusinessLogic.Mappers.DocumentType.Mapping;

namespace BusinessLogic.Mappers.DocumentEnvelopes.Mapping
{
	internal class DocumentEnvelopeMapping : IMapping<DocumentEnvelope, DataControl.Document_Envelope>
	{
		public DataControl.Document_Envelope ToDTO(DocumentEnvelope from)
		{
			var to = new DataControl.Document_Envelope();

			to.DocumentTypeFK = new DocumentTypeMapping().Map(from.DocumentType);
			to.DocXML = from.DocXML;
			to.EnvelopeId = from.ID;
			to.Signature = from.Signature;
			to.StatusFK = new DocumentEnvelopeStatusMapping().Map(from.Status);
			to.SenderFK = from.SenderId;
			to.RejectionReason = from.RejectionReason;
			to.SentDate = from.SentDate;

			return to;
		}

		public DocumentEnvelope ToBE(DataControl.Document_Envelope from)
		{
			var to = new DocumentEnvelope();

			to.DocumentType = new DocumentTypeMapping().Map(from.DocumentTypeFK);
			to.DocXML = from.DocXML;
			to.ID = from.EnvelopeId;
			to.Signature = from.Signature;
			to.Status = new DocumentEnvelopeStatusMapping().Map(from.StatusFK);
			to.SenderId = from.SenderFK;
			to.RejectionReason = from.RejectionReason;
			to.SentDate = from.SentDate;

			return to;
		}
	}
}
